package com.cn.kabalifemerchants.ui.order;

import android.view.View;

import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.cn.kabalifemerchants.R;
import com.cn.kabalifemerchants.base.BasePresenter;
import com.cn.kabalifemerchants.base.LazyFragment;
import com.cn.kabalifemerchants.ui.order.fragment.OrderListFragments;
import com.cn.kabalifemerchants.ui.recruit.adapter.PagerAdapter;
import com.cn.kabalifemerchants.ui.recruit.fragment.RecruitListFragment;
import com.flyco.tablayout.SlidingTabLayout;
import com.flyco.tablayout.listener.OnTabSelectListener;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by 晓林 on 2020/10/14.
 * function:
 */
public class FragmentOrder extends LazyFragment implements OnTabSelectListener {
    @BindView(R.id.slitab)
    SlidingTabLayout slitab;
    @BindView(R.id.vp_type)
    ViewPager vpType;


    List<String> mList = new ArrayList<>();
    PagerAdapter mAdapter;
    private List<Fragment> mFragments = new ArrayList<>();

    @Override
    protected BasePresenter createPresenter() {
        return null;
    }

    @Override
    protected void onUserVisible() {

    }

    @Override
    protected int provideContentViewId() {
        return R.layout.fragment_home_order;
    }

    @Override
    public void initView(View view) {
        super.initView(view);
        ButterKnife.bind(this, view);
        mList.clear();
        mList.add("待接单");
        mList.add("待核价");
        mList.add("待支付");
        mList.add("已完成");
        mList.add("售后");

        for (int i = 0; i < mList.size(); i++) {
            mFragments.add(OrderListFragments.getInstance(i));
        }
        mAdapter = new PagerAdapter(getChildFragmentManager(), mList, mFragments);
        vpType.setAdapter(mAdapter);
        vpType.setOffscreenPageLimit((mList.size() - 1));
        slitab.setViewPager(vpType);
        slitab.setOnTabSelectListener(this);
    }

    @Override
    public void onTabSelect(int position) {

    }

    @Override
    public void onTabReselect(int position) {

    }
}
